package com.destiny.config;

import com.destiny.filter.CrossFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CrossFilterConfig {

  /**
   * 配置过滤器
   * @return
   */
  @Bean
  public FilterRegistrationBean<CrossFilter> crossFilter() {
    FilterRegistrationBean<CrossFilter> registrationBean = new FilterRegistrationBean<>();
    // <filter-class>
    registrationBean.setFilter(new CrossFilter());

    // <url-pattern>
    registrationBean.addUrlPatterns("/*");

    // order
    registrationBean.setOrder(1);
    return registrationBean;
  }

}
